 #include "CustomerView.h"
 
CustomerView::CustomerView()
{
 option = 0;
 fullName = "";
 address = "";
 contactNumber = "";
 email = "";
 customer = null;
 print = "";
 customers = new LinkedList<Customer>();
  
}

 Customer* CustomerView::createCustomer()
{
 print = utilities->getInput("Introducing of Customers\n");
 fullName = utilities->getInput("Enter the Full Name: ");
 contactNumber = utilities->getInput("Enter the Contact Number: ");
 address = utilities->getInput("Enter the Contact Number: ");
 email = utilities->getInput("Enter the Email: ");
 customer = new Customer(fullName,contactNumber,address,email);
 return customer;
 
}

void CustomerView::add()
{
     customer = createCustomer();
     customers->add(customer);
}

void CustomerView::remove()
{
     showCustomers();
     option = utilities->getInt("Choose Which Delete: ");
     option--;
     customers->remove(option);  

}
void CustomerView::edit()
{
     showCustomers();
     option = utilities->getInt("Choose Which Modify: ");
     option--;
     customer = createCustomer(); 
     customers->edit(customer,option);
}

void CustomerView::showCustomers()
{

Node<Customer>* i = customers->getFirst();
int x = 1;

while(i != NULL){

        cout << "Customer No." << x++ << "\n";
        cout << "FullName: " << i->getData()->getFullName() <<"\n"; 
        cout << "Contact Number: " << i->getData()->getContactNumber() << "\n";
        cout << "Address: " << i->getData()->getAddress() << "\n";
        cout << "Email: " << i->getData()->getEmail() << "\n\n";
        i = i->getNext();        
  }      
} 
 
void CustomerView::show()
{
 utilities->clearScreen(); 
 utilities->printText( " Maintenances Of Customers\n"); 
 utilities->printText("1. Add Customer: \n");
 utilities->printText("2. Modify Customer: \n");
 utilities->printText("3. Delete Customer: \n");
 utilities->printText("4. Exit: \n");
 option = utilities->getInt("Choose The Option: ");
 
 switch(option){
 
 case 1:
  utilities->clearScreen();   
  add(); 
  show(); 
  break;

 case 2: 
  utilities->clearScreen(); 
  edit(); 
  show();
  break;
  
 case 3: 
  utilities->clearScreen();
  remove();
  show(); 
  break;

}  
}
